<?php
/**
 * ============================================================================
 * Copyright (c) 2015-2018 贵州大师兄信息技术有限公司 All rights reserved.
 * siteַ: http://www.dsxcms.com
 * ============================================================================
 * @author:     David Song<songdewei@163.com>
 * @version:    v1.0.0
 * ---------------------------------------------
 * Date: 2018/10/25
 * Time: 8:37 PM
 */

namespace App\WeChat\Pay;


class JsApiPay
{
    private $content = [
        'body' => '',
        'out_trade_no' => '',
        'total_fee' => 0,
        'spbill_create_ip' => '', // 可选，如不传该参数，SDK 将会自动获取相应 IP 地址
        'notify_url' => '', // 支付结果通知网址，如果不设置则会使用配置里的默认地址
        'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
        'openid' => '',
    ];

    public function setBody($body)
    {
        $this->content['body'] = $body;
        return $this;
    }

    public function setOutTradeNo($out_trade_no)
    {
        $this->content['out_trade_no'] = $out_trade_no;
        return $this;
    }

    public function setTotalFee($total_fee)
    {
        $this->content['total_fee'] = $total_fee;
        return $this;
    }

    public function setSpbillCreateIp($spbill_create_ip)
    {
        $this->content['spbill_create_ip'] = $spbill_create_ip;
        return $this;
    }

    public function setNotifyUrl($notify_url)
    {
        $this->content['notify_url'] = $notify_url;
        return $this;
    }

    public function setOpenid($openid)
    {
        $this->content['openid'] = $openid;
        return $this;
    }

    public function getBizContent()
    {
        if (!$this->content['notify_url'])
        {
            $this->content['notify_url'] = config('wechat.payment.default.notify_url');
        }
        return $this->content;
    }
}
